package cn.udinghuo.model.voucher.freight;

import com.fasterxml.jackson.annotation.JsonSetter;

import org.springframework.util.Assert;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Column;
import java.util.Map;
import java.util.HashMap;
import cn.udinghuo.core.domain.entity.BaseAuditTenant;	
import java.math.BigDecimal;	
import cn.udinghuo.model.voucher.freight.FreightRule;	
import cn.udinghuo.model.voucher.freight.FreightWay;	
import cn.udinghuo.model.voucher.freight.FreightWayTypeEnum;	
import cn.udinghuo.model.voucher.freight.PriceCountTypeEnum;	
import cn.udinghuo.core.domain.entity.Comment;
import cn.udinghuo.core.domain.entity.ita.CacheKey;

/**
 * @author xufla
 *	运费方式设置
 */
@Entity
@Table(name="freightwaysettings")
public class FreightWaySettings extends BaseAuditTenant<Long>  {

	private static final long serialVersionUID = -50331649L;
	/**
	* 运费方式类型freightWayType
	*/
	@Comment(value="运费方式类型")
	@Column(name="iFreightWayType")
	private Short freightWayType;
	/**
	* 阶梯顺序gradeOrder
	*/
	@Comment(value="阶梯顺序")
	@Column(name="iGradeOrder")
	private Short gradeOrder;
	/**
	* 阶梯名称gradeName
	*/
	@Comment(value="阶梯名称")
	@Column(name="cGradeName", length = 50)
	private String gradeName;
	/**
	* 阶梯值gradeValue
	*/
	@Comment(value="阶梯值")
	@Column(name="fGradeValue")
	private BigDecimal gradeValue;
	/**
	* 阶梯单位gradeUnit
	*/
	@Comment(value="阶梯单位")
	@Column(name="cGradeUnit", length = 50)
	private String gradeUnit;
	/**
	* 阶梯费用名称gradePriceName
	*/
	@Comment(value="阶梯费用名称")
	@Column(name="cGgradePriceName", length = 50)
	private String gradePriceName;
	/**
	* 阶梯金额gradePrice
	*/
	@Comment(value="阶梯金额")
	@Column(name="fGradePrice")
	private BigDecimal gradePrice;
	/**
	* 阶梯金额计算类型gradePriceCountType
	*/
	@Comment(value="阶梯金额计算类型")
	@Column(name="iGradePriceCountType")
	private Short gradePriceCountType;
	/**
	* 运费方式idfreightWayId
	*/
	@Comment(value="运费方式id")
	@Column(name="iFreightWayId")
	private Long freightWayId;
	/**
	* 模板idfreightRuleId
	*/
	@Comment(value="模板id")
	@Column(name="iFreightRuleId")
	private Long freightRuleId;
	public FreightWayTypeEnum getFreightWayType() {
        if(this.freightWayType == null){
			return null;
		}
		return FreightWayTypeEnum.find(this.freightWayType.intValue());
	}
	@JsonSetter
	public void setFreightWayType(FreightWayTypeEnum value) {
		Assert.notNull(value, "enum value is invalid value!");
		this.freightWayType = value.getValue();
	}
	
	public void setFreightWayType(Short value) {
		Assert.notNull(value,"enum value is invalid value!");
		Assert.notNull(FreightWayTypeEnum.find(value.intValue()),"enum value is invalid value!"); 
		this.freightWayType = value;
	}
	
	public Short getGradeOrder() {
		return this.gradeOrder;
	}
	
	public void setGradeOrder(Short value) {
		this.gradeOrder = value;
	}
	
	public String getGradeName() {
		return this.gradeName;
	}
	
	public void setGradeName(String value) {
		this.gradeName = value;
	}
	
	public BigDecimal getGradeValue() {
		return this.gradeValue;
	}
	
	public void setGradeValue(BigDecimal value) {
		this.gradeValue = value;
	}
	
	public String getGradeUnit() {
		return this.gradeUnit;
	}
	
	public void setGradeUnit(String value) {
		this.gradeUnit = value;
	}
	
	public String getGradePriceName() {
		return this.gradePriceName;
	}
	
	public void setGradePriceName(String value) {
		this.gradePriceName = value;
	}
	
	public BigDecimal getGradePrice() {
		return this.gradePrice;
	}
	
	public void setGradePrice(BigDecimal value) {
		this.gradePrice = value;
	}
	
	public PriceCountTypeEnum getGradePriceCountType() {
        if(this.gradePriceCountType == null){
			return null;
		}
		return PriceCountTypeEnum.find(this.gradePriceCountType.intValue());
	}
	@JsonSetter
	public void setGradePriceCountType(PriceCountTypeEnum value) {
		Assert.notNull(value, "enum value is invalid value!");
		this.gradePriceCountType = value.getValue();
	}
	
	public void setGradePriceCountType(Short value) {
		Assert.notNull(value,"enum value is invalid value!");
		Assert.notNull(PriceCountTypeEnum.find(value.intValue()),"enum value is invalid value!"); 
		this.gradePriceCountType = value;
	}
	
	public Long getFreightWayId() {
		return this.freightWayId;
	}
	
	public void setFreightWayId(Long value) {
		this.freightWayId = value;
	}
	
    
	public FreightWay getFreightWay() {
		return (FreightWay) this.getTransient("freightWay");
	}
	
	public void setFreightWay(FreightWay value) {
		this.putTransient("freightWay",value);
	}
	
	public Long getFreightRuleId() {
		return this.freightRuleId;
	}
	
	public void setFreightRuleId(Long value) {
		this.freightRuleId = value;
	}
	
    
	public FreightRule getFreightRule() {
		return (FreightRule) this.getTransient("freightRule");
	}
	
	public void setFreightRule(FreightRule value) {
		this.putTransient("freightRule",value);
	}
	
}
